<template>
	<view class="page must_know" :style="{'min-height':h+'px','padding-top':(mt)+'px'}">
		<c-nav-bar :title="title"></c-nav-bar>
		<u-swiper imgMode="scaleToFill" :list="detailsList" @change="e => currentNum = e.current" :autoplay="false"
			indicatorStyle="right: 20px" height='750rpx' style="margin-bottom: 30rpx;">
		</u-swiper>
		<view class="basicInfo">
			<view class="chaoji">
				{{alldata.name}}
			</view>
			<!-- <view class="xianzhi">
				<view class="xianzhi1">
					限制
				</view>
				<view class="xianzhi2">
					不限制
				</view>
			</view> -->
			<view class="xuzhi">
				<view class="xuzhi1">
					须知
				</view>
				<view class="xuzhi2">
					<view class="yyyue1" v-for="(item,index) in  noticelist" :key="index">
						*{{item.notice}}
					</view>

				</view>
			</view>
			<view class="chaoji">
				套餐明细
			</view>
			<view class="taocanmx">
				<view class="taocanlistmx" v-for="(item,index) in  productsDetaillist" :key="index">
					<view class="taocanlistmx1">
						*{{item.name}}
					</view>
					<view class="taocanlistmx2">
						（{{item.number}}{{!isNaN(item.number)?'份':''}}）
					</view>
					<view class="taocanlistmx3">
						¥ {{item.price}}
					</view>
				</view>


			</view>

		</view>
		<view class="wuyiyi">

		</view>
		<view class="basicInfo">
			<view class="chaoji">
				购买须知
			</view>
			<view class="xianzhi">
				<view class="xianzhi1">
					有效期
				</view>
				<view class="xianzhi2">
					{{activityStartTime}}至{{activityEndTime}}
				</view>
			</view>
			<view class="chaoji" style="margin: 20rpx 0 0 0;">
				规则说明
			</view>
			<view class="xuzhinew">
				<view class="xuzhi1new">
					使用规则
				</view>
				<view class="xuzhi2new">
					<view class="yyyue1new" v-for="(item,index) in  useRulelist" :key="index">
						*{{item.useRule}}
					</view>


				</view>
			</view>
		</view>
		<view class="wuyiyi">

		</view>
		<view class="basicInfo">
			<view class="chaoji">
				参与商户
			</view>
			<view class="canyu">
				<view class="canyu1">
					<u--image :src="shangjia.storeFrontPic" width="190rox" height="190rpx"></u--image>
				</view>
				<view class="canyu2">
					<view class="papdang1">
						<view class="haixian1">
							<view class="xhpd1">
								{{shangjia.name}}
							</view>
							<view class="xhpd2">
								<view class="xhpd2new">
									{{categorytext}}
								</view>
								<view class="xhpd2new">
									{{xzName}}
								</view>
							</view>
						</view>
						<view class="haixian2" @click="phone(shangjia.phone)">
							<u--image src="https://i.ringzle.com/file/20240313/a03fb2d09dcd4ca29f4a3467024d28ca.png"
								width="56rpx" height="56rpx"></u--image>
						</view>
					</view>
					<view class="papdang2">
						<view class="yingyez1">
							营业中
						</view>
						<view class="yingyez2">
							{{shangjia.openDate}}
						</view>
					</view>
					<view class="papdang3">
						<view class="dizhinew1">
							<u--image src="https://i.ringzle.com/file/20240313/7fec127b4f6f494daa6a3df04d711487.png"
								width="20rpx" height="25rpx"></u--image>
						</view>
						<view class="dizhinew2">
							{{shangjia.areaDetail}}

						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="wuyiyi" style="margin-bottom: 170rpx;">

		</view>
		<view class="goumai">
			<view class="goumai1">
				<view class="zongji1">
					总计：
				</view>
				<view class="zongji2">
					¥
				</view>
				<view class="zongji3">
					{{alldata.discountPrice}}
				</view>
				<view class="zongji4">
					<span
						style="text-decoration: line-through;color: #999;font-size: 20rpx">￥{{alldata.price}}</span><del></del>
				</view>
			</view>
			<view class="goumai2" @click="goumai">
				立即购买
			</view>
		</view>


		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '套餐详情',
				h: uni.getSystemInfoSync().windowHeight,
				mt: uni.getSystemInfoSync().statusBarHeight + 44,
				detailsList: [],
				alldata: {},
				merchantId: '', //商户ID
				noticelist: [],
				productsDetaillist: [],
				useRulelist: [],
				activityStartTime: '',
				activityEndTime: '',
				shangjia: {},
				msflName: '',
				xzName: '',
				categorytext: '',

			}
		},

		onLoad(option) {
			this.$api.get(`/api/merchant/food/${JSON.parse(option.list).id}`).then(res => {
				this.alldata = res.data.data;
				this.detailsList = res.data.data.coverImg.split(',');
				this.noticelist = JSON.parse(res.data.data.notice);
				this.productsDetaillist = JSON.parse(res.data.data.productsDetail);
				this.useRulelist = JSON.parse(res.data.data.useRule);
				this.activityStartTime = res.data.data.activityStartTime.substring(0, 10);
				this.activityEndTime = res.data.data.activityEndTime.substring(0, 10);

				this.merchantId = res.data.data.merchantId;
				this.shanghuxinxi();
			})
			if (option.msflName) this.msflName = option.msflName;
			if (option.xzName) this.xzName = option.xzName;

		},
		methods: {
			async shanghuxinxi() {
				let hcs = await this.getHousekeeping();
				this.$api.get('/api/merchant/food/merchant/' + this.merchantId).then(res => {
					this.shangjia = res.data.data;
					this.shangjia.storeFrontPic = this.shangjia.storeFrontPic.split(',')[0];
					let t = hcs.find(h => h.dictValue == this.shangjia.foodType);
					if (t) {
						this.categorytext = t.dictLabel
					}
				})
			},
			async getHousekeeping() {
				return new Promise((resolve, reject) => {
					this.$api.get('/sys/dict/type/all').then(res => {
						if (res.data.code === 0) {
							let alldata = res.data.data.find((p) => p.dictType == 'food_type')
								.dataList;
							resolve(alldata);
						} else reject()
					})
				})
			},

			// 联系商家
			phone(e) {
				uni.makePhoneCall({
					phoneNumber: e //仅为示例
				});
			},
			goumai() {
				uni.navigateTo({
					//url: '/pagesTrip/fineFood/fineFood/orderforgoods',
					url: '/pagesTrip/fineFood/fineFood/orderforgoods?list=' + JSON.stringify({
						...this.alldata
					})
				})
			},

		}
	}
</script>
<style lang="scss" scoped>
	.page {
		padding-bottom: 140rpx;
	}

	.goumai {
		position: fixed;
		bottom: 0rpx;
		left: 30rpx;
		background: #fff;
		width: 690rpx;
		height: 140rpx;
		margin: 0 auto;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.goumai2 {
			width: 220rpx;
			height: 88rpx;
			background: #007A69;
			border-radius: 44px;
			font-family: PingFang-SC, PingFang-SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #FFFFFF;
			line-height: 88rpx;
			text-align: center;
			font-style: normal;
		}

		.goumai1 {
			flex-grow: 1;
			height: 140rpx;
			display: flex;
			align-items: center;

			.zongji1 {
				height: 140rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #666666;
				line-height: 140rpx;
				text-align: left;
				font-style: normal;
			}

			.zongji2 {
				height: 140rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #FF4141;
				line-height: 140rpx;
				text-align: left;
				font-style: normal;
			}

			.zongji3 {
				height: 140rpx;
				font-family: DINAlternate, DINAlternate;
				font-weight: bold;
				font-size: 48rpx;
				color: #FF4141;
				line-height: 140rpx;
				text-align: left;
				font-style: normal;
				padding: 0 8rpx;
			}

			.zongji4 {}
		}
	}

	.canyu {
		width: 100%;
		display: flex;
		margin: 40rpx 0 40rpx 0;

		.canyu1 {
			width: 190rpx;
			height: 190rpx;
		}

		.canyu2 {
			width: calc(100% - 190rpx);
			flex-grow: 1;
			box-sizing: border-box;

			.papdang1 {
				width: 100%;
				display: flex;

				.haixian2 {
					width: 56rpx;
					display: flex;
					justify-content: center;
					align-items: center;
				}

				.haixian1 {
					flex-grow: 1;

					.xhpd1 {
						width: 100%;
						font-family: PingFang-SC, PingFang-SC;
						font-weight: bold;
						font-size: 32rpx;
						color: #111111;
						line-height: 47.5rpx;
						text-align: left;
						font-style: normal;
						padding-left: 20rpx;
					}

					.xhpd2 {
						width: 100%;
						display: flex;
						align-items: center;
						padding-left: 20rpx;

						.xhpd2new {
							font-family: PingFangSC, PingFang SC;
							font-weight: 400;
							font-size: 24rpx;
							color: #777777;
							line-height: 47.5rpx;
							text-align: left;
							font-style: normal;
							padding-right: 20rpx;
						}
					}
				}
			}

			.papdang2 {
				display: flex;
				padding-left: 20rpx;

				.yingyez1 {
					width: 78rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 26rpx;
					color: #333333;
					line-height: 47.5rpx;
					text-align: justify;
					font-style: normal;
				}

				.yingyez2 {
					flex-grow: 1;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 26rpx;
					color: #333333;
					line-height: 47.5rpx;
					text-align: left;
					font-style: normal;
				}
			}

			.papdang3 {
				padding-left: 20rpx;
				display: flex;
				align-items: center;

				.dizhinew1 {
					width: 30rpx;
					display: flex;
					align-items: center;
					justify-content: center;
				}

				.dizhinew2 {
					flex-grow: 1;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 26rpx;
					color: #333333;
					line-height: 47.5rpx;
					text-align: justify;
					font-style: normal;
				}
			}
		}

	}

	.yyyue1new {
		width: 100%;
		min-height: 55rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 26rpx;
		color: #111111;
		line-height: 45rpx;
		text-align: left;
		font-style: normal;
	}

	.xuzhinew {
		width: 100%;
		min-height: 130rpx;
		display: flex;
		margin: 30rpx 0;

		.xuzhi1new {
			width: 136rpx;
			height: 55rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 26rpx;
			color: #666666;
			line-height: 45rpx;
			text-align: left;
			font-style: normal;
		}

		.xuzhi2new {
			flex-grow: 1;
		}
	}

	.taocanlistnewmx1 {
		width: 460rpx;
		height: 50rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 26rpx;
		color: #111111;
		line-height: 50rpx;
		text-align: left;
		font-style: normal;
	}

	.wuyiyi {
		width: 750rpx;
		height: 20rpx;
		background: #F5F8FA;
	}

	.taocanmx {
		margin: 30rpx 0;

		.taocanlistmx {
			display: flex;

			.taocanlistmx1 {
				width: 460rpx;
				height: 50rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 26rpx;
				color: #111111;
				line-height: 50rpx;
				text-align: left;
				font-style: normal;
			}

			.taocanlistmx2 {
				width: 150rpx;
				height: 50rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 26rpx;
				color: #999999;
				line-height: 50rpx;
				text-align: center;
				font-style: normal;
			}

			.taocanlistmx3 {
				width: 80rpx;
				height: 50rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 26rpx;
				color: #111111;
				line-height: 50rpx;
				text-align: right;
				font-style: normal;
			}
		}
	}

	.yyyue1 {
		width: 100%;
		height: 55rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 26rpx;
		color: #111111;
		line-height: 55rpx;
		text-align: left;
		font-style: normal;
	}

	.xuzhi {
		width: 100%;
		// min-height: 130rpx;
		display: flex;
		margin-top: 20rpx;

		.xuzhi1 {
			width: 90rpx;
			height: 55rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 26rpx;
			color: #666666;
			line-height: 55rpx;
			text-align: left;
			font-style: normal;
		}

		.xuzhi2 {
			flex-grow: 1;
		}
	}

	.basicInfo {
		width: 690rpx;
		margin: 0 auto;

		.chaoji {
			width: 100%;
			height: 40rpx;
			font-family: PingFang-SC, PingFang-SC;
			font-weight: bold;
			font-size: 40rpx;
			color: #1C1E41;
			line-height: 40rpx;
			text-align: left;
			font-style: normal;
			margin: 40rpx 0 0 0;
		}

		.xianzhi {
			width: 100%;
			// height: 110rpx;
			display: flex;
			margin-top: 30rpx;

			.xianzhi1 {
				width: 90rpx;
				height: 110rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 26rpx;
				color: #666666;
				line-height: 110rpx;
				text-align: left;
				font-style: normal;
			}

			.xianzhi2 {
				width: 600rpx;
				height: 110rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 26rpx;
				color: #111111;
				line-height: 110rpx;
				text-align: left;
				font-style: normal;
			}

		}

	}
</style>